#pragma once

#include <process.h>

#define WM_THREAD_EXIT		WM_USER + 4000
namespace COMMONLIB
{


class SingleThread
{
public:
	typedef struct tagTHREAD_PARAM
	{
		LPVOID p;
		HANDLE hEvent;
	} THREAD_PARAM;

	SingleThread();
	virtual ~SingleThread();


	BOOL CreateThread();
	void Exit(DWORD dwWaitTime);
	void PostThreadMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);

	virtual UINT DoThreadWork()	= 0;
	virtual void NotifyExit() = 0;

private:
	static UINT WINAPI __ThreadProc(LPVOID lpParam);	
	void WaitAndForceExit(DWORD dwWait);

private:
	HANDLE m_hThread;
	DWORD m_dwThreadID;
};

}